<template>
  <div id="div">
    <div class="box">
      <div @click="fun()"><van-icon name="arrow-left" /></div>
      <div id="maodian">
        <a href="#shangpin">商品</a>
        <a href="#jieshao">详情</a>
      </div>
      <div><van-icon name="more-o" /></div>
    </div>
    <div id="shangpin" class="box2">
      <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item><img :src="img[0]" alt="" /></van-swipe-item>
        <van-swipe-item><img :src="img[1]" alt="" /></van-swipe-item>
        <van-swipe-item><img :src="img[2]" alt="" /></van-swipe-item>
        <van-swipe-item><img :src="img[3]" alt="" /></van-swipe-item>
        <van-swipe-item><img :src="img[4]" alt="" /></van-swipe-item>
      </van-swipe>
    </div>
    <div class="box3">
      <p class="jiage">￥{{ jiage }}</p>
      <h3>{{ text }}</h3>
      <p class="miaoshu">
        <span>千年酒韵 一脉相承</span><span>销量:6050 &nbsp;&nbsp;&nbsp;</span>
      </p>
    </div>
    <div class="box5">
      <router-link to="#"> 套餐一 </router-link>
      <router-link to="#1">套餐二</router-link>
      <router-link to="#2">套餐三</router-link>
    </div>
    <div class="box6">
      <div>
        <button class="jian" @click="jian()">-</button>
        <input class="number" :value="num" type="text" />
        <button class="zeng" @click="zeng()">+</button>
      </div>
      <div>
        总价:<span>{{ zongjia }}</span>
      </div>
    </div>
    <h3 id="jieshao">产品介绍</h3>
    <div class="img">
      <div v-for="(v, i) in xqimg" :key="i + 'a'">
        <img :src="v" alt="" />
      </div>
    </div>
    <div class="request" @click="request()">立即购买</div>
  </div>
</template>

<script>
import { shangpinzhifu } from "@/apis/lifelink1.js";
export default {
  data() {
    return {
      img: [
        "./img/life/spxqy_lbt (1).jpg",
        "./img/life/spxqy_lbt (2).jpg",
        "./img/life/spxqy_lbt (3).jpg",
        "./img/life/spxqy_lbt (4).jpg",
        "./img/life/spxqy_lbt (5).jpg",
      ],
      xqimg: [
        "./img/life/wuliangye/1.jpg",
        "./img/life/wuliangye/2.jpg",
        "./img/life/wuliangye/3.jpg",
        "./img/life/wuliangye/4.jpg",
        "./img/life/wuliangye/5.jpg",
        "./img/life/wuliangye/6.jpg",
        "./img/life/wuliangye/7.jpg",
        "./img/life/wuliangye/8.jpg",
        "./img/life/wuliangye/9.jpg",
        "./img/life/wuliangye/10.jpg",
        "./img/life/wuliangye/11.jpg",
        "./img/life/wuliangye/12.jpg",
        "./img/life/wuliangye/13.jpg",
        "./img/life/wuliangye/14.jpg",
        "./img/life/wuliangye/15.jpg",
      ],
      text: "五粮液-第八代-浓香型-52度-500ml",
      arr: "五粮液",
      jiage: "1499.00",
      num: "1",
    };
  },
  computed: {
    zongjia() {
      return this.num * this.jiage;
    },
  },
  methods: {
    request() {
      shangpinzhifu({
        body: this.text,
        subject: this.arr,
        amount: this.zongjia,
      }).then((res) => {
        console.log(res.request.responseURL);
        // this.$router.push("./res.request.responseURL");
        window.open(res.request.responseURL, "_blank");
      });
    },
    zeng() {
      return (this.num = this.num / 1 + 1);
    },
    jian() {
      if (this.num > 0) {
        return (this.num -= 1);
      } else {
        return this.num;
      }
    },
    fun() {
      this.$router.push("./life");
    },
    onClickButton() {
      this.$router.push("./zhifuyemian");
    },
  },
};
</script>
    
<style lang="scss" scoped>
.request {
  width: 100%;
  height: 0.5rem;
  background-color: red;
  color: #fff;
  position: fixed;
  bottom: 0rem;
  font-size: 0.18rem;
  text-align: center;
  line-height: 0.5rem;
}
#maodian {
  > a {
    display: inline-block;
    padding: 0 0.1rem;
  }
}
.img {
  width: 100%;
  > div > img {
    width: 100%;
  }
}
.null {
  width: 100%;
  height: 0.5rem;
}
.box6 {
  margin-top: 0.1rem;
  box-sizing: border-box;
  width: 100%;
  height: 0.5rem;
  padding: 0.1rem;
  display: flex;
  justify-content: space-between;
  > div:nth-child(2) {
    > span {
      color: red;
    }
  }
  > div:nth-child(1) {
    > .jian,
    > .zeng {
      display: inline-block;
      width: 0.3rem;
      height: 0.3rem;
      background-color: #777;
    }
    > .number {
      text-align: center;
      width: 0.3rem;
    }
  }
}
.box5 {
  width: 100%;
  height: 0.4rem;
  line-height: 0.3rem;
  > a {
    display: inline-block;
    margin: 0.1rem;
    background-color: #fff;
    padding: 0.05rem;
  }
  > .router-link-exact-active {
    background-color: skyblue;
  }
}
#div {
  background-color: #eee;
}
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 0.2rem;
  text-align: center;
  background-color: #fff;
}
.box2 {
  width: 100%;
  img {
    width: 100%;
  }
}
.box3 {
  width: 100%;
  line-height: 0.3rem;
  background-color: #fff;
  text-indent: 1em;
  > .jiage {
    width: 100%;
    color: red;
  }
  > .miaoshu {
    display: flex;
    justify-content: space-between;
    color: #999;
    > span {
      font-size: 0.14rem;
    }
  }
}
.box {
  border-bottom: 1px solid #999;
  position: fixed;
  top: 0;
  z-index: 5;
  background-color: #fff;
  opacity: 0.8;
  width: 100%;
  height: 0.5rem;
  display: flex;
  line-height: 0.5rem;
  text-align: center;
  justify-content: space-between;
  > div:nth-child(2) {
    display: flex;
    justify-content: space-between;
    > div {
      width: 0.4rem;
    }
  }
  > div:nth-child(1),
  > div:nth-child(3) {
    width: 0.5rem;
  }
}
</style>